<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单id" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入订单id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户id" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入用户id(外键)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户姓名" prop="realName">
        <el-input
          v-model="queryParams.realName"
          placeholder="请输入用户姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品id" prop="productId">
        <el-input
          v-model="queryParams.productId"
          placeholder="请输入产品id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">

      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleSend"
        >合同生成并发送</el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleSend"
        >合同生成并发送</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:order:export']"
        >导出</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单编号" align="center" prop="orderId" width="50"/>
      <el-table-column label="用户编号" align="center" prop="userId" width="50"/>
      <el-table-column label="用户名" align="center" prop="realName" width="50"/>
      <el-table-column label="产品编号" align="center" prop="productId" width="50"/>
      <el-table-column label="产品名称" align="center" prop="productName" width="65"/>
      <el-table-column label="提交时间" align="center" prop="commitTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.commitTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="申请金额" align="center" prop="applymoney" width="70"/>
      <el-table-column label="贷款期限" align="center" prop="loanTerm" width="70">
        <template slot-scope="scope">
                  <span v-if="scope.row.loanTerm=='0'">1个月</span>
                  <span v-else-if="scope.row.loanTerm=='1'">3个月</span>
                  <span v-else-if="scope.row.loanTerm=='2'">6个月</span>
                  <span v-else-if="scope.row.loanTerm=='3'">9个月</span>
                  <span v-else-if="scope.row.loanTerm=='4'">12个月</span>
                  <span v-else-if="scope.row.loanTerm=='5'">18个月</span>
                  <span v-else-if="scope.row.loanTerm=='6'">24个月</span>
                  <span v-else="scope.row.loanTerm=='7'">36个月</span>
          </template>
      </el-table-column>
      <el-table-column label="还款方式" align="center" prop="paymentMethod" width="90">
        <template slot-scope="scope">
                  <span v-if="scope.row.paymentMethod=='0'">等额本息</span>
                  <span v-else-if="scope.row.paymentMethod=='1'">等本等息</span>
                  <span v-else-if="scope.row.paymentMethod=='2'">先息后本</span>
                  <span v-else="scope.row.paymentMethod=='3'">一次性还息付本</span>
          </template>
        </el-table-column>
      
      <el-table-column label="还款状态" align="center" prop="paymentStatus" width="90">
        <template slot-scope="scope">
                  <span v-if="scope.row.paymentStatus=='0'">未还款</span>
                  <span v-else="scope.row.paymentStatus=='1'">已还款</span>
          </template>
      </el-table-column>

      <el-table-column label="审核人" align="center" prop="auditor" width="65"/>
      <el-table-column label="审核状态" align="center" prop="auditStatus"  width="65">
      <template slot-scope="scope">
                  <span v-if="scope.row.auditStatus=='0'">未审核</span>
                  <span v-else-if="scope.row.auditStatus=='1'">通过</span>
                  <span v-else="scope.row.auditStatus=='2'">拒绝</span>
          </template> 
      </el-table-column>
      <el-table-column label="订单状态" align="center" prop="orderStatus" width="65"> 
        <template slot-scope="scope">
          <span v-if="scope.row.orderStatus == '0'">未发放</span>
          <span v-else="scope.row.orderStatus=='1'">已发放</span>
          <span v-else="scope.row.orderStatus=='2'">失效</span>
          </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="95">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="95">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      
      
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="50">
        <template slot-scope="scope">
          <el-button
          v-if="auditStatus!='0'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleExamine(scope.row)"
          >初审</el-button>
         
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:order:remove']"
          >删除</el-button> -->
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="70">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >复审</el-button>
          
        </template>
      </el-table-column>
      
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page-sizes="[5, 10, 15, 20]"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 生成合同对话框 -->
     <el-dialog :title="title" :visible.sync="add" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="合同编号" prop="contractNumber">
          <el-input v-model="form.contractNumber" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同名" prop="contractName">
          <el-input v-model="form.contractName" placeholder="请输入合同名" />
        </el-form-item>
        <el-form-item label="发起人电话" prop="initiatorPhone">
          <el-input v-model="form.initiatorPhone" placeholder="请输入发起人电话" />
        </el-form-item>
        <el-form-item label="合同来源" prop="contractSource">
          <el-input v-model="form.contractSource" placeholder="请输入合同来源" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSend">确 定</el-button>
        <el-button @click="cancelcontract">取 消</el-button>
      </div>
    </el-dialog> 
    <!--审核弹窗 -->
     <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      
        <el-collapse v-model="activeNames" @change="handleChange()">
          <el-collapse-item>
              <template slot="title">
                <h1>用户详情</h1>
              </template>
            <template>
              <el-descriptions class="margin-top"  :column="3" :size="size" border>
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        用户编号 
                      </template>
                        <span>{{userData.userId}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        用户姓名
                      </template>
                      <span>{{userData.realName}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-mobile-phone"></i>
                        用户电话
                      </template>
                      <span>{{userData.userPhone}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        身份证
                      </template>
                      <span>{{userData.identityCard}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        银行卡号
                      </template>
                      <span>{{userData.bankCard}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-location-outline"></i>
                        家庭住址
                      </template>
                      <span>{{userData.address}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        教育程度
                      </template>
                      <span>{{userData.educationLevel}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        职业
                      </template>
                      <span>{{userData.occupation}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        月收入
                      </template>
                      <span>{{userData.occupation}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        房权证号
                      </template>
                      <span>{{userData.houseCertificate}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        信用情况
                      </template>
                      <span>{{userData.creditStanding}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        贷款说明
                      </template>
                      <span>{{userData.loanDescription}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        紧急联系人电话
                      </template>
                      <span>{{userData.emergencyPhone}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-user"></i>
                        更新时间
                      </template>
                      <span>{{userData.updateTime}}</span>
                    </el-descriptions-item>

                  </el-descriptions>

                  </template>
                </el-collapse-item>

          
              <el-collapse-item>
              <template slot="title">
                <h1>产品详情</h1>
              </template>
              <template>
              <el-descriptions class="margin-top"  :column="3" :size="size" border>
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        产品编号 
                      </template>
                        <span>{{productData.id}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        产品名称 
                      </template>
                        <span>{{productData.productName}}</span>
                    </el-descriptions-item>
                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        图片 
                      </template>
                        <span>{{productData.image}}</span>
                    </el-descriptions-item>
                    
                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        资金方 
                      </template>
                        <span>{{productData.escrow}}</span>
                    </el-descriptions-item>
                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        审核状态Y 
                      </template>
                        <span v-if="productData.auditStatus=='0'">未审核</span>
                        <span v-else="productData.auditStatus=='1'">已审核</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        启用状态Y 
                      </template>
                       
                        <span v-if="productData.enableStatus=='0'">未启用</span>
                        <span v-else="productData.enableStatus=='1'">已启用</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        月利率
                      </template>
                        <span>{{productData.monthRate}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        咨询费率
                      </template>
                        <span>{{productData.consultingRate}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        保证金费率
                      </template>
                        <span>{{productData.marginRate}}</span>
                    </el-descriptions-item>

                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        还款方式
                      </template>
                      <span v-if="productData.paymentMethod=='0'">等额本息</span>
                      <span v-else-if="productData.paymentMethod=='1'">等本等息</span>
                      <span v-else-if="productData.paymentMethod=='2'">先息后本</span>
                      <span v-else="productData.paymentMethod=='3'">一次性环息付本</span>
                    </el-descriptions-item>

                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        贷款期限
                      </template>
                        <span v-if="productData.loanTerm=='0'">1个月</span>
                        <span v-else-if="productData.loanTerm=='1'">3个月</span>
                        <span v-else-if="productData.loanTerm=='2'">6个月</span>
                        <span v-else-if="productData.loanTerm=='3'">9个月</span>
                        <span v-else-if="productData.loanTerm=='4'">12个月</span>
                        <span v-else-if="productData.loanTerm=='5'">18个月</span>
                        <span v-else-if="productData.loanTerm=='6'">24个月</span>
                        <span v-else="productData.loanTerm=='7'">36个月</span>
                    </el-descriptions-item>

                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        创建者
                      </template>
                        <span>{{productData.creater}}</span>
                    </el-descriptions-item>

                    
                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        更新者
                      </template>
                        <span>{{productData.updater}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        创建时间
                      </template>
                        <span>{{productData.creatTime}}</span>
                    </el-descriptions-item>

                    <el-descriptions-item>
                      <template slot="label">
                        <i class="el-icon-tickets"></i>
                        更新时间
                      </template>
                        <span>{{productData.updateTime}}</span>
                    </el-descriptions-item>

              </el-descriptions> 
              </template>     
            </el-collapse-item>

            <el-collapse-item>
              <template slot="title">
                <h1>人工审核</h1>
              </template>

                    <el-collapse-item>
                    <template slot="title">
                      <h2>征信</h2>
                    </template>
                        
                    <el-descriptions class="margin-top"  :column="1" :size="size" border>   
                      <el-descriptions-item>
                         <template slot="label">
                             信用记录是否空白
                          </template>
                          <el-switch
                          v-model="manualReviewData.creditRecordStatus"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          active-text="是"
                          inactive-text="否">
                      </el-switch>
                    </el-descriptions-item>

                    <el-descriptions-item>
                         <template slot="label">
                             用户是否有过逾期行为
                          </template>
                          <el-switch
                          v-model="manualReviewData.hadOverdueStatus"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          active-text="是"
                          inactive-text="否">
                      </el-switch>
                    </el-descriptions-item>

                    <el-descriptions-item>
                         <template slot="label">
                             用户申请金额是否超过还款能力
                          </template>
                          <el-switch
                          v-model="manualReviewData.hadExceedsCapacity"
                          active-color="#13ce66"
                          inactive-color="#ff4949"
                          active-text="是"
                          inactive-text="否">
                      </el-switch>
                    </el-descriptions-item>
                      
                    </el-descriptions> 
                    
                   
                    </el-collapse-item>

                    <el-collapse-item>
                    <template slot="title">
                      <h2>反欺诈</h2>
                    </template>
                              <el-descriptions class="margin-top"  :column="1" :size="size" border>   
                                <el-descriptions-item>
                                  <template slot="label">
                                    申请人是否存在被执行记录
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadExecutedRecord"
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>

                              <el-descriptions-item>
                                  <template slot="label">
                                    申请人是否存在失信记录
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadDishonestyRecord"
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>
                                
                              </el-descriptions> 
                    </el-collapse-item>

                    <el-collapse-item>
                    <template slot="title">
                      <h2>电话审核</h2>
                    </template>
                    <el-descriptions class="margin-top"  :column="1" :size="size" border>   
                                <el-descriptions-item>
                                  <template slot="label">
                                    是否为被调查对象本人接听
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadOneself"
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>

                              <el-descriptions-item>
                                  <template slot="label">
                                    身份证核实是否一致
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadIdentityCards "
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>

                              <el-descriptions-item>
                                  <template slot="label">
                                    紧急联系人是否一致
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadEmergencyPhone"
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>

                              <el-descriptions-item>
                                  <template slot="label">
                                    当前住址与申请表是否一致
                                    </template>
                                    <el-switch
                                    v-model="manualReviewData.hadAddress"
                                    active-color="#13ce66"
                                    inactive-color="#ff4949"
                                    active-text="是"
                                    inactive-text="否">
                                </el-switch>
                              </el-descriptions-item>
                                
                              </el-descriptions>
                    </el-collapse-item>

            </el-collapse-item>
            </el-collapse>
     
      <div slot="footer" class="dialog-footer">
        <div style="width:30%">
          <tr>
            <td><h3>审核员:</h3></td>
          <td>
            <el-input
               v-model="one.auditor"
                placeholder="请输入姓名"
               clearable
            />
          </td>
      </tr>
          
         
        </div>
        
 
       
    
        <el-button type="primary" :disabled="submit" @click="examineSubmit">通 过</el-button>
        <el-button type="danger"  :disabled="reject" @click="examineReject">拒 绝</el-button>
        <el-button type="success"  :disabled="upd" @click="examineUpd">修 改</el-button>
        <el-button type="warning" @click="cancel">取 消</el-button>
      </div>
    </el-dialog> 
  </div>
</template>

<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder,addContract } from "@/api/credit/creOrder";
import { getProducts } from "@/api/credit/creproduct";
import { getUser } from "@/api/credit/creUser";
// import { reject } from "q";
import { listExamine,addExamine,listExamineByOrderId,updateExamine} from "../../api/credit/creExamine"; 
import { listExamineNew,getExamineNew,addExamineNew,updateExamineNew,delExamineNew,getExamineNewByOrderId,machineAudit,getUserName} from "@/api/credit/creExamineNew"; 

export default {
  name: "Order",
  data() {
    return {
      //审核人名字
      auditName:null,

      nshow: true, //switch开启
        fshow: false, //switch关闭

      //审核面板记录
      manualReviewData:{
        examineId:0,
        orderId:0,
        creditRecordStatus:true,
        hadOverdueStatus:true,
        hadExceedsCapacity:true,
        hadExecutedRecord:true,
        hadDishonestyRecord:true,
        hadOneself:true,
        hadIdentityCards:true,
        hadEmergencyPhone:true,
        hadAddress:true
      },
      // manualReviewData:{},


      //审核面板 通过和拒绝 按钮状态
      submit:null,
      reject:null,
      upd:null,

      //订单列表实体id
      oneId:null,
      //审核通过及拒绝发送的实体
      one:{
        orderId:null,
        auditor:null,
        audit_status:null,
      },


      //描述列表属性
      size:'',
      //折叠面板属性
      activeNames: ['1'],
      //审核页面用户数据id
      userId:null,
      //审核页面产品数据id
      productId:null,
      //订单页面编号id
      orderId:null,
      //通过订单id查询审核表的json数据
      creJson:{
        orderId:null,
      },
      //审核状态
      auditStatus:null,
      // //审核按钮状态
      // examineButton:false,
      // //审核修改按钮状态
      // examineUpdButton:false,
      //用户数据
      userData:{},
      //产品数据
      productData:{},
      //审核数据
      examineData:{},
    //
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示合同弹出层
      add: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 5,
        orderId: null,
        userId: null,
        productId: null,
        realName: null,
        productName: null,
        contractNumber: null,
          contractName: null,
          initiator: null,
          initiatorPhone: null,
          completionTime: null,
          contractSource: null,
          contractStatus: null,
          creatTime:null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.getAuditName();
    // creJson.orderId = row.orderId;
    //   getOrderNew(this.creJson).then(response=>{
    //     this.auditStatus = response.data.auditStatus;
    //   });
    //  if(this.auditStatus == "0"){
    //   this.examineButton = false;
    //   this.examineUpdButton = true;
    //  }else{
    //   this.examineButton = true;
    //   this.examineUpdButton = false;
    //  }
  },
  methods: {
     //获得审核人名字
     getAuditName(){
         getUserName().then(response=>{
         this.auditName = response.msg;
       })
    },

    //折叠面板方法
    handleChange(val) {
     
    },
    
    // 审核表单重置
    resetManualReviewData(){
      this.manualReviewData = {
        examineId:0,
        orderId:0,
        creditRecordStatus:true,
        hadOverdueStatus:true,
        hadExceedsCapacity:true,
        hadExecutedRecord:true,
        hadDishonestyRecord:true,
        hadOneself:true,
        hadIdentityCards:true,
        hadEmergencyPhone:true,
        hadAddress:true
      };
    },

    /** 审核按钮操作 */
    handleExamine(row) {
      // this.$router.push({
      //   path:'/creditExamine',
      //   query:{
      //     orderId:12,
      //   },
      // });

      this.$router.push({
        path:"/creditExamine",
        query:{
          orderId:row.orderId,
          userId:row.userId,
          productId:row.productId,
          auditStatus:row.auditStatus,
        }
      })

      // this.resetManualReviewData();

      // this.upd=true;
      // if(row.auditStatus=='0'){
      //     this.submit=false;
      //     this.reject=false;
      // }

      // if(row.auditStatus!='0'){
      //   this.submit=true;
      //   this.reject=true;
      // }

      // this.manualReviewData.orderId= row.orderId;
      // this.auditor = row.auditor;
      // this.oneId = row.orderId;
      // this.userId = row.userId;
      // this.productId = row.productId;
      // this.creJson.orderId = row.orderId;
      // this.title = "审核订单";
      // this.open = true;

      // getUser(this.userId).then(response=>{
      //    this.userData = response.data; 
      // });
      // getProducts(this.productId).then(response=>{
      //     this.productData = response.data;
      // });
     
      
      // this.getList();
     

    },

    /** 审核修改按钮操作 */
    handleUpdate(row) {
      var username = this.$store.state.user.name;
              this.form.initiator=username;
      this.$router.push({
        path:"/creditExamineUpd",
        query:{
          orderId:row.orderId,
          userId:row.userId,
          productId:row.productId,
          auditStatus:row.auditStatus,
        }
      });
      
      // this.resetManualReviewData();
     
      //   this.submit=true;
      //   this.reject=true;

      //   this.upd=false;

      // this.auditor = row.auditor;
      // this.oneId = row.orderId;
      // this.userId = row.userId;
      // this.productId = row.productId;
      // this.creJson.orderId = row.orderId;
      // this.title = "修改审核订单";
      // this.open = true;
      // console.log(row.orderId);

      // getUser(this.userId).then(response=>{
      //    this.userData = response.data; 
      // });
      // getProducts(this.productId).then(response=>{
      //     this.productData = response.data;
      // });
      // listExamineByOrderId(this.creJson).then(response=>{
        
      //   this.manualReviewData = response.data;
      // })
     
      // this.getList();
     

    },
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    cancelcontract() {
      this.add = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        userId: null,
        commitTime: null,
        userName: null,
        productName: null,
        requestedAmount: null,
        loanTerm: null,
        status: null,
        contractNumber: null,
          contractName: null,
          initiator: null,
          initiatorPhone: null,
          completionTime: null,
          contractSource: null,
          contractStatus: null,
          creatTime:null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = (selection.map(item => item.auditStatus)[0])!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },

    
    /**审核表通过按钮 */

   
    /** 合同生成按钮操作 */
    handleSend() {
      var username = this.$store.state.user.name;
      this.reset();
      this.form.initiator=username;
      this.add = true;
      this.title = "合同生成";
    },
    /**审核表提交按钮 */
    examineSubmit(){
     
      if(this.title=="审核订单"){
        
        addExamine(this.manualReviewData).then(response=>{
          console.log(this.manualReviewData);
         
          this.one.orderId = this.oneId;
          this.one.auditStatus=1;
          updateOrder(this.one);
          this.$modal.msgSuccess("审核通过");
          this.open=false;
          this.getList();
        })
        
      }

      this.getList();
    },

      /**审核表拒绝按钮 */
    examineReject(){
      
      if(this.title=="审核订单"){
        
        addExamine(this.manualReviewData).then(response=>{
          console.log(this.manualReviewData);
         
          this.one.orderId = this.oneId;
          this.one.auditStatus=2;
          updateOrder(this.one);
          this.$modal.msgSuccess("审核拒绝");
          this.open=false;
         this.getList();
        })
        
     
      }
    },

    /**审核表修改*/
    examineUpd(){
      if(this.title=="修改审核订单"){
        
        updateExamine(this.manualReviewData).then(response=>{
          console.log(this.manualReviewData);
         
          this.one.orderId = this.oneId;
          updateOrder(this.one);

          this.$modal.msgSuccess("修改审核表成功");
          this.open=false;
         this.getList();
        })
        
     
      }
    },

    /**发送消息 */
    // sendMessage(row){
    //   if(row.auditStatus == "1"){
    //     sendTest()
    //   }
    // },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
     /** 合同生成提交按钮 */
     submitSend(){
      addContract(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.add = false;
              this.getList();
            });
     },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + orderIds + '"的数据项？').then(function() {
        return delOrder(orderIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/order/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
